
import org.eclipse.swt.widgets.Shell;
import org.eclipse.swt.widgets.Button;
import org.eclipse.swt.widgets.Text;
import org.eclipse.swt.SWT;
import org.eclipse.swt.events.SelectionAdapter;
import org.eclipse.swt.events.SelectionEvent;

public class AlertSender
{
    public static Shell shell = null;

    public static void sendAlert(String message)
    {
        if (shell == null)
        {
            System.out.println(message);
        }
        else
        {
            final Shell dialog = new Shell(shell, SWT.DIALOG_TRIM | SWT.APPLICATION_MODAL);
            Button ok = new Button(dialog, SWT.PUSH);
            Text text = new Text(dialog, SWT.NATIVE | SWT.CENTER | SWT.MULTI | SWT.WRAP);

            ok.setText("ok");
            text.setText(message);

            text.setBounds(20,40,230,70);
            ok.setBounds(95,110,80,30);

            dialog.setMinimumSize(270,180);

            ok.addSelectionListener(new SelectionAdapter()
            {   public void widgetSelected(SelectionEvent e)
                {
                    dialog.close();
                }
            });

            dialog.setDefaultButton(ok);
            dialog.setText("ALERT");
            dialog.pack();
            dialog.open();
        }
    }

    public static void init(Shell shell)
    {
        AlertSender.shell = shell;
    }
}
